package my.example.samplegridview;

import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;

public class persistancestorage{
	private String _prefname = "CART";
	private Context _context;
	private SharedPreferences _settings;
	
	public persistancestorage(Context _context){
		this._context = _context;
		this._settings = this._context.getSharedPreferences(_prefname, 0);
	}
	
	public boolean putValueString(String key,String value){
		SharedPreferences.Editor editor = _settings.edit();
		editor.putString(key, value);
	    return editor.commit();
	}
	
	public String getValueString(String key){
		if(!this._settings.contains(key))
			return null;
		return this._settings.getString(key, "");
	}
	
	public Map<?, ?> getAllValue(){
		return this._settings.getAll();
	}
	
	public void clearAllValue(){
		SharedPreferences.Editor editor = _settings.edit();
		editor.clear();
		editor.commit();
	}
}
